import Vue from 'vue';
import VeeValidate,{Validator} from 'vee-validate';
import zh_CN from 'vee-validate/dist/locale/zh_CN';
import {phoneReg,codeReg,pwdReg} from '@/utils/reg'

Vue.use(VeeValidate);
Validator.localize('zh_CN', zh_CN);

Validator.extend('shouji_guize', {
  getMessage: () => '手机号格式不合法',
  validate: value => phoneReg.test(value)
});

Validator.extend('yanma_guize', {
  getMessage: () => '验证码必须为6为纯数字',
  validate: value => codeReg.test(value)
});

Validator.extend('mima_guize', {
  getMessage: () => '密码必须由英文、数字、下划线组成',
  validate: value => pwdReg.test(value)
});

Validator.extend('xieyi_guize', {
  getMessage: () => '协议必须同意！',
  validate: value => value === true
});